package com.xzz.web.controller;

import com.xzz.dto.SmsCodeDto;
import com.xzz.result.JSONResult;
import com.xzz.service.IVerifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

    @Autowired
    private IVerifyService verifyService;

    //图形验证码接口
    @RequestMapping("/imageCode/{imageCodeKey}")
    public JSONResult imageVerifyCode(@PathVariable("imageCodeKey") String imageCodeKey) {
        String value = verifyService.getImgCode(imageCodeKey);
        return JSONResult.success(value);
    }

    /**
     * 获取手机验证码接口
     * @param smsCodeDto
     * @return
     */
    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@Valid @RequestBody SmsCodeDto smsCodeDto){
        verifyService.sendSmsCode(smsCodeDto);
        return JSONResult.success();
    }
}